﻿using System.Collections.Generic;
using System.Linq;
using UIT.ScrumTool.Client.ControlService;
using UIT.ScrumTool.Client.Utilities.StoryTaskGridView;
using UIT.ScrumTool.Client.Utilities.TaskGridView;

namespace UIT.ScrumTool.Client.Controller
{
    public class TaskCtrl
    {
        #region Thuoc Tinh

        private static readonly TaskServiceClient taskServiceClient = new TaskServiceClient();

        #endregion

        #region Lay Table Task

        public static TaskBindingListComplete TaskTable()
        {
            TaskBindingListComplete taskBindingListComplete=new TaskBindingListComplete();
            List<TaskDto> list = taskServiceClient.TaskGetByAll().ToList();
            foreach (TaskDto taskDto in list)
            {
                taskBindingListComplete.Add(new TaskEditTable("ST" + taskDto.Id.ToString().Trim(), taskDto.Subject,
                                                              taskDto.Description, taskDto.EstmatedStoryPoint,
                                                              taskDto.Importance, taskDto.OperatorId, taskDto.SprintId,
                                                              taskDto.ProjectId, taskDto.Height, taskDto.Color,taskDto.EstimatedDuration));
            }
            return taskBindingListComplete;
        }

        #endregion

        public static List<TaskDto> TaskGetByParentId(int parentId)
        {
            return taskServiceClient.TaskGetByParentId(parentId).ToList();
        }

        public static List<StoryTaskShow> StoryTaskGetByAll()
        {
            List<StoryTaskShow> lstStoryTaskShows=new List<StoryTaskShow>();
            List<TaskDto> lstStory = taskServiceClient.TaskGetByParentId(0).ToList();
            foreach (var story in lstStory)
            {
                lstStoryTaskShows.Add(StoryTaskShow.CreateStoryTaskShow(story));
            }
            return lstStoryTaskShows;
        }
    }
}